<template>
    <div class='cold'>
        <el-row class="tac">
            <el-col :span="4" class='cols' v-if="type!='simple'">
               
                <div class='menu ' style="overflow:hidden">
                     <div class='left_tree_head'>
                        寄存区选择
                    </div>
                    <div class='mytree2'>
                    <el-tree
                        :data="leftMenu"
                        :props="defaultProps"
                        node-key="id"
                        ref="elMenu"
                        class="tree-line2"
                        check-strictly
                        
                        highlight-current
                        :default-expanded-keys="defaultShowNodes"
                        @node-click="handleNodeClick2"
                        @check-change="handleNodeClick">
                    </el-tree>
                    </div>
                   <div class="tree_bottom" v-if="sCode=='txbyg'">
                        <el-row>
                            <el-col :span="12"><div>总位数:{{totalSize}}</div></el-col>
                            <el-col :span="12"><div style="color:rgb(4, 111, 193)">已使用:{{zy}}</div></el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12"> <div style="color:rgb(241, 112, 161)">已停用:{{ty}}</div></el-col>
                            <el-col :span="12"><div style="color:#67C23A">已标记:{{bj}}</div></el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12"> <div>剩余:{{sy}}</div></el-col>
                            <el-col :span="12"></el-col>
                        </el-row>
                        
                        
                   </div>
                </div>
                
                
            </el-col>
            <el-col :span="spancontent" class='cols2'>
               
                <div class='buttons' v-if="isSelect!='Y'">
                    
                        <el-dropdown>
                            <el-button type="primary">
                                寄存区管理<i class="el-icon-arrow-down el-icon--right"></i>
                            </el-button>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item icon="el-icon-circle-plus-outline" @click.native="openAddArea('/commonEdit','0')">新增区</el-dropdown-item>
                                <el-dropdown-item icon="el-icon-edit-outline"  @click.native="openEditArea('/commonEdit')">修改区</el-dropdown-item>
                                <el-dropdown-item icon="el-icon-delete" @click.native="delArea()">删除区</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>

                        <el-dropdown style='margin-left:10px'>
                            <el-button type="success">
                                寄存位管理<i class="el-icon-arrow-down el-icon--right"></i>
                            </el-button>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item icon="el-icon-circle-plus-outline" @click.native="openWin('新增寄存位#/commonEdit#殡仪馆系统/骨灰处理/寄存位')">编辑寄存位</el-dropdown-item>
                                <el-dropdown-item icon="el-icon-edit-outline"  @click.native="openWin2('批量新增寄存位#/commonEdit#殡仪馆系统/骨灰处理/寄存位管理/批量新增寄存位#bygex')">批量新增寄存位</el-dropdown-item>
                                <!--el-dropdown-item icon="el-icon-tickets"   @click.native="openWin2('批量修改寄存位#/commonEdit#殡仪馆系统/骨灰处理/寄存位管理/批量修改寄存位2#bygex')">批量修改寄存位</el-dropdown-item-->
                                <el-dropdown-item icon="el-icon-delete" @click.native="delMw()">删除寄存位</el-dropdown-item>
                                <el-dropdown-item icon="el-icon-delete" @click.native="setTy()">停用寄存位</el-dropdown-item>
                                <el-dropdown-item icon="el-icon-delete" @click.native="setQy()">启用寄存位</el-dropdown-item>
                                <el-dropdown-item icon="el-icon-delete" @click.native="setBj()" v-if="sCode=='txbyg'">标记寄存位</el-dropdown-item>
                                <el-dropdown-item icon="el-icon-delete" @click.native="setBjCancel()"  v-if="sCode=='txbyg'">取消标记寄存位</el-dropdown-item>
                            </el-dropdown-menu> 
                        </el-dropdown>
                        <el-button type="primary" style="margin-left:10px;" v-if="showType!='simple'" @click="showTypeChange('simple')">
                            简单信息
                        </el-button>
                        <el-button type="primary" v-else  @click="showTypeChange('normal')" style="margin-left:10px;" >
                            详细信息
                        </el-button>
                </div>
                <div v-if="type=='simple'">
                    <el-button-group>
                        <el-button class="roomBtn" :type="roomActive==index ? 'primary':''" v-for="(item,index) in rooms" :key="index" @click="handleClick(item,index)">{{item.title}}</el-button>
                        
                    </el-button-group>
                </div>
                <div class='content_main'>
                    
                    <div class='contents'  v-loading="loading"  >
                    
                        <div class='contents_left' ref="contents_left">
                            <div class='contents_left_head' style='height:50px'>&nbsp;</div>
                            <div class='contents_left_content'>
                                <div class='contents_left_content_item' v-for="index of maxRow" :key="index" :style='{"height":oneHeight2,"lineHeight":oneHeight2}'>
                                    
                                </div>
                            </div>
                        </div>
                        <div class='contents_right'>
                            <div class='contents_head' ref="contents_head_item">
                                <div   :style="{'width':maxWdith+'px'}" >
                                <div class='contents_head_item'  v-for="index of maxCol" :key="index"  :style='{"width":oneWidth2}'>
                                    
                                </div>
                                </div>
                            </div>
                            <div class='contents_gm' ref="contents"  @scroll="sysHandleScroll()">
                                <div class='contents_gm_c'>
                                    <input type='checkbox' id="all" @click="checkedAll(locItems)" v-if="locItems.length>0 && isCheckbox=='Y'"/><label for="all"  v-if="locItems.length>0&& isCheckbox=='Y'">全选</label>
                                
                                    <div class='car_row' v-for="(item,index) in locItems" :key="index" :style="item.widths2" >
                                        <input type='checkbox' :style='{"float":"left","marginTop":checkTop}' @click="checkedMore(item.child)" v-if="isCheckbox=='Y'"/>
                                        <div class='card_item' v-for="(child,index2) in item.child" :key="index2" :style='{"marginBottom":"10px","marginRight":"5px","width":oneWidth}'>
                                            <el-card :body-style="{ padding: '0px' }" >
                                                <div   v-if="child.type=='寄存位'" @dblclick="openItem(item,index,index2)" @click="itemClick(item,index,index2)"  :class="child.className" :style='{"height":oneHeight,"background":child.background}'>
                                                    <div class='gm_child'>
                                                        <div :class='child.head'  v-if="child.loc_ex5">
                                                            <input type='checkbox' class="ginput" style='float:left' @click="checkedOne(child.loc_id)" :checked="fruitIds.indexOf(child.loc_id)>=0"  v-if="isCheckbox=='Y'"/>
                                                            <input type='checkbox'  class="ginput" style='float:left'  :checked="fruitIds.indexOf(child.loc_id)>=0" @click="itemClick(item,index,index2)" v-if="(isSelect=='Y'||(isCheckbox!='Y'))&&item.loc_ex4!='N'" />
                                                            <!--i class='icon iconfont icon-iconfontzhizuobiaozhunbduan27' style='font-size:12px;color:#fff;margin-right:2px;vertical-align: middle' v-if="child.gm_ex9=='未出售'&&isCheckbox!='Y'&&isSelect!='Y'"></i>
                                                            <i class='icon iconfont icon-goumai' style='font-size:14px;color:#fff;margin-right:2px;vertical-align: middle' v-if="child.gm_ex9=='购买'&&isCheckbox!='Y'&&isSelect!='Y'"></i>
                                                            <i class='icon iconfont icon-leimupinleifenleileibie'   style='font-size:12px;color:#fff;margin-right:2px;vertical-align: middle' v-if="child.gm_ex9=='部分安葬'&&isCheckbox!='Y'&&isSelect!='Y'"></i>
                                                            <i class='icon iconfont icon-quanbu' style='font-size:10px;color:#fff;margin-right:2px;vertical-align: middle' v-if="child.gm_ex9=='全部安葬'&&isCheckbox!='Y'&&isSelect!='Y'"></i>
                                                            <i class='icon iconfont icon-yudingbaoliu' style='font-size:12px;color:#fff;margin-right:2px;vertical-align: middle' v-if="child.gm_ex9=='预定'&&isCheckbox!='Y'&&isSelect!='Y'"></i-->
                                                            <span style='display:inline-block;vertical-align: middle;font-weight:bold'>{{child.loc_ex5}} </span>
                                                            <!--span v-if="child.noCheckout" style='color:red;font-size:10px'>(未结)</span-->
                                                        </div>
                                                        <div :class='child.head'  v-else>
                                                            {{child.loc_ex2}}-{{child.loc_ex3}}
                                                        </div>
                                                         <div class='gm_content' v-if="showType!='simple'">
                                                             <div >编号:{{child.sz_ex2}}</div>
                                                             <div style='text-align:left'>姓名:{{child.sz_ex3}}</div>
                                                             <div style='text-align:left'>性别:{{child.sz_ex4}}</div>
                                                             <div style='text-align:left'>年龄:{{child.sz_ex5}}</div>
                                                        </div>
                                                        <!--div class='gm_content' v-html="child.namenews" :class="child.content">
                                                        
                                                        </div-->
                                                        <div class="bottom clearfix" style='font-size:13px'>
                                                        
                                                            
                                                           
                                                        </div>
                                                        <div class='bottom_text' style='display:none'>
                                                            
                                                        </div>
                                                    </div>
                                                </div>

                                                <div v-if="child.type=='空地'" class='gm'  :style='{"height":oneHeight}'>
                                                    <div class='gm_child'>
                                                        <div class='head5' >
                                                            空地
                                                        </div>
                                                        <div class='gm_content'>
                                                        
                                                        </div>
                                                        <div class="bottom clearfix" style='font-size:13px'>
                                                        </div>
                                                    </div>
                                                </div>

                                            </el-card>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                        </div>
                        
                        
                        


                    </div>
                </div>
            </el-col>
        </el-row>
        
      
    </div>
</template>
<script>
export default {
    props:["isSelect","data","exkey","pId"],
    data(){
        return{
            items:[],
            locItems:[],
            src:"",
            room:"",
            rooms:[],
            roomActive:0,
            appid:"bygex",
            defaultProps: {
                children: 'child',
                label: 'title'
            },
            leftMenu:[],
            active:'',
            areaId:"",
            defaultShowNodes:[],
            property:"",
            
            maxRow:1,
            maxCol:1,
            oneWidth:"",
            oneWidth2:"",
            oneHeight:"",
            oneHeight2:"",
            isCheckbox:"",
            fruitIds:[],
            clickItems:[],
            loading:false,
            maxWdith:0,
            totalSize:0,
            zy:0,
            sy:0,
            bj:0,
            ty:0,
            type:"",
            spancontent:20,
            url:"byg/storageLoc/readSzLocItem",
            sCode:localStorage.getItem("sCode"),
            checkTop:"65px",
            showType:localStorage.getItem("storageShowType")
        }
    },
    inject: ['openWin2'],
    created(){
        /* if(this.$route.query.appid){
            this.appid=this.$route.query.appid;
        }*/
        
        this.loadLeft();
        if(this.isSelect!='Y'){
            this.isCheckbox="Y"
        }
        if(this.sCode=="ntbyg"){
            this.url="ntStorage/readSzLocItem"
        }
        if(this.$route.query.type){
            this.type=this.$route.query.type;
        }
        if(this.type=="simple"){
            this.spancontent=24
        }
    },
    updated(){
        console.log("update======================")
    },
    methods:{
        setTy(){
           
            let msg="确定要停用该寄存位?";
            let url="/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/寄存设置/停用&isSend=Y"
            this.$confirm(msg, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                   
                    this.$post("business",url,{"ids":this.fruitIds.join(",")}).then(data=>{
                         if(data[0].status=="+OK"){
                            this.$message({
                                message: unescape(data[0].msg),
                                    type: 'success'
                                });
                            this.goSearch()
                        }else{
                            this.$alert(unescape(data[0].msg), '错误提示', {
                                confirmButtonText: '确定',
                                callback: action => {}
                            });
                        }
                    })
                }).catch(() => {
                         
            });
        },
        setQy(){
           
            let msg="确定要启用该寄存位?";
            let url="/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/寄存设置/启用&isSend=Y"
            this.$confirm(msg, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                   
                    this.$post("business",url,{"ids":this.fruitIds.join(",")}).then(data=>{
                         if(data[0].status=="+OK"){
                            this.$message({
                                message: unescape(data[0].msg),
                                    type: 'success'
                                });
                            this.goSearch()
                        }else{
                            this.$alert(unescape(data[0].msg), '错误提示', {
                                confirmButtonText: '确定',
                                callback: action => {}
                            });
                        }
                    })
                }).catch(() => {
                         
            });
        },
        
        setBj(){
           
           let msg="确定要标记该寄存位?";
           let url="/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/寄存设置/标记寄存位&isSend=Y"
           this.$confirm(msg, '提示', {
               confirmButtonText: '确定',
               cancelButtonText: '取消',
               type: 'warning'
               }).then(() => {
                  
                   this.$post("business",url,{"ids":this.fruitIds.join(",")}).then(data=>{
                        if(data[0].status=="+OK"){
                           this.$message({
                               message: unescape(data[0].msg),
                                   type: 'success'
                               });
                           this.goSearch()
                       }else{
                           this.$alert(unescape(data[0].msg), '错误提示', {
                               confirmButtonText: '确定',
                               callback: action => {}
                           });
                       }
                   })
               }).catch(() => {
                        
           });
        },
        setBjCancel(){
           
           let msg="确定要取消标记该寄存位?";
           let url="/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/寄存设置/取消标记寄存位&isSend=Y"
           this.$confirm(msg, '提示', {
               confirmButtonText: '确定',
               cancelButtonText: '取消',
               type: 'warning'
               }).then(() => {
                  
                   this.$post("business",url,{"ids":this.fruitIds.join(",")}).then(data=>{
                        if(data[0].status=="+OK"){
                           this.$message({
                               message: unescape(data[0].msg),
                                   type: 'success'
                               });
                           this.goSearch()
                       }else{
                           this.$alert(unescape(data[0].msg), '错误提示', {
                               confirmButtonText: '确定',
                               callback: action => {}
                           });
                       }
                   })
               }).catch(() => {
                        
           });
        },
        selectOk(){
            console.log("selectok================================")
            console.log(this.clickItem);
            for(let key in this.exkey){
                try{
                    this.$set(this.data[this.pId],key,this.clickItem[this.exkey[key]])
                }catch(e){}
            }
            return true;
        },
        changeItem(item,index){
            this.room=item.loc_ex1;
            this.loadDataItem();
            let el=document.getElementsByClassName("tab");
            for(let i=0;i<el.length;i++){
                el[i].classList.remove("active");
            }
            document.getElementsByClassName("tab")[index].classList.add("active");
        },
        loadData(){
            this.$post(this.appid,"byg/storageLoc/readRoom",{}).then(data=>{
                this.items=data;
                if(this.items.length>0){
                    this.room=this.items[0].loc_ex1;
                    this.loadDataItem();
                    window.setTimeout(function(){
                        document.getElementsByClassName("tab")[0].classList.add("active");
                    },1000)
                }
                
            });
        },
        loadDataItem(){
            this.$post(this.appid,this.url,{sRoom:escape(this.room)}).then(data=>{
                this.locItems=data;
                
            })
        },
        loadRight(active){
            this.$post(this.appid,this.url,{area:escape(this.active)}).then(data=>{
                
               this.locItems=data.data;
               this.maxWdith=data.widths;
               this.maxRow=Number(data.maxRow);
               this.maxCol=Number(data.maxCol);
               this.oneWidth=data.oneWidth+"px";
               this.oneHeight=data.oneHeight+"px";
               this.oneHeight2=data.oneHeight2+"px";
               this.oneWidth2=(Number(data.oneWidth)+4)+"px"
               this.totalSize=data.totalSize;
               this.zy=data.zy;
               this.sy=data.sy;
               this.bj=data.bj;
               this.ty=data.ty
               this.showTypeChange(this.showType)
            })
        },
        add(){
           

            let data={};
            data.buttonName="新增寄存位"
            data.url="/commonEdit";
            data.fieldPath="lc_lg";
            data.filename2="殡仪馆系统/骨灰处理/寄存位";
            data.appid="business";
            this.$emit("openWin",JSON.stringify(data))
        },
        edit(item){


            let data={};
            data.buttonName="编辑寄存位"
            data.url="/commonEdit";
            data.fieldPath="lc_lg";
            data.filename2="殡仪馆系统/骨灰处理/寄存位";
            data.appid="business";
            this.$emit("openWin",JSON.stringify(data))
        },
        initData(){
            this.loadLeft();
        },
        showTypeChange(type){
            this.showType=type;
            localStorage.setItem("storageShowType",type)
            
            if(type=="simple"){
                this.oneWidth="60px";
                this.oneHeight="60px";
                this.oneHeight2="70px";
                this.oneWidth2="64px";
                for(let i=0;i<this.locItems.length;i++){
                    this.locItems[i].widths_simple="height:70px;width:"+(this.maxCol*70)+"px"
                    this.locItems[i].widths2="height:70px;width:"+(this.maxCol*70)+"px"

                }
                this.checkTop="20px"
            }else{
                this.oneWidth="140px";
                this.oneHeight="140px";
                this.oneHeight2="150px";
                this.oneWidth2="144px";
                for(let i=0;i<this.locItems.length;i++){
                   
                    this.locItems[i].widths2=this.locItems[i].widths

                }
                this.checkTop="65px"
            }
           
        },
        goSearch(){
            this.loadLeft();
            
        },
        loadLeft(){
            this.fruitIds=[];
            console.log("appid========="+this.appid);
            this.$post("bygex","/byg/storageLoc/getAarea",{gm_id:this.gm_idMain}).then(data=>{
               
                this.leftMenu=data;
                let child=null;
                if(this.leftMenu.length>0){
                    if(this.active){
                         this.defaultShowNodes=[];
                         this.defaultShowNodes.push(this.active);
                         this.loadRight(this.active)
                    }else{
                        
                        let isOk=true;
                        child=this.leftMenu[0].child;
                        while(isOk){
                            if(child.length>0){
                                if(child[0].child&&child[0].child.length>0)
                                    child=child[0].child;
                                else
                                    isOk=false;
                            }else{
                                isOk=false;
                            }
                        }
                        this.active=child[0].id;
                        this.loadRight(child[0].id)
                        this.defaultShowNodes=[];
                        this.defaultShowNodes.push(child[0].id);
                        
                        this.gm_id=child[0].pId;
                        this.areaId=child[0].id;
                        try{
                            this.$refs.elMenu.setCheckedKeys([child[0].id]);
                        }catch(e){}
                        


                    }
                    
                    if(this.type=="simple"){
                        this.rooms=this.leftMenu[0].child
                    }
                    
                }else{
                     this.loading=false;
                     this.loadhide();
                    
                }
               
                
            })
        },
        openAddArea(url,type){
               let pId=this.areaId;
               if(!pId||pId==undefined||pId=="undefined"||pId.indexOf("p")!=-1){
                   pId="-1";
               }
               //alert(this.areaId)
            //if(this.areaId){
                let datas={};
                datas.buttonName="新增区";
                datas.url=url;
                datas.exId=this.gm_id;
                datas.sId="";
                datas.pId=pId;
                datas.width="500px";
                datas.height="350px";
                datas.filename2="殡仪馆系统/骨灰处理/寄存区管理/新增寄存区";
                datas.appid="business";
                this.$emit("openWin",JSON.stringify(datas))
                //parent.postMessage(JSON.stringify(datas),'*');
           /* }else{
                this.$alert('请先选择一行数据', '错误提示', {
                    confirmButtonText: '确定',
                    callback: action => {}
                });
                return;
            }*/
            
        },
        openEditArea(url){
            if(this.areaId){
                let datas={};
                datas.buttonName="修改区";
                datas.url=url;
                datas.exId=this.gm_id;
                datas.sId=this.areaId;
                datas.width="500px";
                datas.height="350px";
                datas.filename2="殡仪馆系统/骨灰处理/寄存区管理/修改寄存区";
                datas.appid="business";
                this.$emit("openWin",JSON.stringify(datas))
                //parent.postMessage(JSON.stringify(datas),'*');
            }else{
                this.$alert('请先选择一行数据', '错误提示', {
                    confirmButtonText: '确定',
                    callback: action => {}
                });
                return;
            }
            
        },
        openPlGm(){
            if(this.fruitIds.length>0){
                let datas={};
                datas.buttonName="批量购买";
                datas.url="/commonEdit";
                datas.exId="";
                datas.sId="";
                datas.ids=this.fruitIds.join(",");
                datas.width="80VH";
                datas.height="76VH";
                datas.left="10VH";
                datas.top="12VH"
                datas.filename2="公墓信息管理系统/业务管理/批量购买";
                datas.appid="business";
                this.$emit("openWin",JSON.stringify(datas))
                //parent.postMessage(JSON.stringify(datas),'*');
            }else{
                this.$alert('请先选择一行数据', '错误提示', {
                    confirmButtonText: '确定',
                    callback: action => {}
                });
                return;
            }
        },
         openPlGm2(){
            if(this.fruitIds.length>0){
                let datas={};
                datas.buttonName="迁坟登记";
                datas.url="/commonEdit";
                datas.exId="";
                datas.sId="";
                datas.ids=this.fruitIds.join(",");
                datas.width="80VH";
                datas.height="76VH";
                datas.left="10VH";
                datas.top="12VH"
                datas.filename2="公墓信息管理系统/业务管理/迁坟管理/迁坟登记";
                datas.appid="business";
                this.$emit("openWin",JSON.stringify(datas))
                //parent.postMessage(JSON.stringify(datas),'*');
            }else{
                this.$alert('请先选择一行数据', '错误提示', {
                    confirmButtonText: '确定',
                    callback: action => {}
                });
                return;
            }
        },
        openWin(url){
            let id="";
            if(this.fruitIds.length>0){
                id=this.fruitIds[this.fruitIds.length-1];
            }
            console.log("fruitIds===============");
            console.log(this.fruitIds)
            let urls=url.split("#");
            let datas={};
            datas.buttonName=urls[0];
            datas.url=urls[1];
            //datas.pId=this.gm_id;
            datas.exId=this.areaId;
            datas.sId=id;
            datas.width="650px";
            datas.height="450px";
            datas.filename2=urls[2];
            datas.appid=urls.length>3 ? urls[3]:"business";
            this.$emit("openWin",JSON.stringify(datas))
           // parent.postMessage(JSON.stringify(datas),'*');
        },
        openWin2(url){
            let urls=url.split("#");
            let datas={};
            datas.buttonName=urls[0];
            datas.url=urls[1];
            datas.sId=this.areaId;
            datas.exId=this.gm_id;
            datas.width="850px";
            datas.height="550px";
            datas.filename2=urls[2];
            datas.appid=urls.length>3 ? urls[3]:"business";
            this.$emit("openWin",JSON.stringify(datas))
           // parent.postMessage(JSON.stringify(datas),'*');
        },
        
        openWin4(url){
            let urls=url.split("#");
            let datas={};
            datas.buttonName=urls[0];
            datas.url=urls[1];
            datas.sId=this.fruitIds.join(",");
            datas.width="650px";
            datas.height="450px";
            datas.filename2=urls[2];
            datas.appid=urls.length>3 ? urls[3]:"business";
            this.$emit("openWin",JSON.stringify(datas))
           // parent.postMessage(JSON.stringify(datas),'*');
        },
         delArea(){
             this.$confirm('此操作将永久删除该寄存区, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post("business","/api/view/delCommonEdit",{ids:this.areaId,filename:"殡仪馆系统/骨灰处理/寄存区管理/修改寄存区"}).then(data=>{
                    this.$message(unescape(data[0].msg));
                    this.goSearch()
                });
            }).catch(() => {
                         
            });
        },
        delMw(){
             this.$confirm('此操作将永久删除选中的寄存位, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post("business","/api/view/delCommonEdit",{ids:this.fruitIds.join(","),filename:"殡仪馆系统/骨灰处理/寄存位"}).then(data=>{
                    this.$message(unescape(data[0].msg));
                    this.goSearch()
                });
            }).catch(() => {
                         
            });
        },
        openLc(item){
            let sz_id=item.sz_id;
           /* let data={};
            data.buttonName="寄存登记"

            data.url="/commonEdit?fieldPath=sz%255Finfo&filename2="+escape(escape("骨灰处理/寄存登记"))+"&sKey=549&appid=business&company=&sId="+sz_id+"&modelId=3&title=业务管理&oldId=1&oldtitle=殡仪馆业务信息管理系统";
            this.$emit("openWin",JSON.stringify(data))

            
            */
            let data={};
            data.buttonName="寄存登记"
            data.url="/commonEdit";
            data.fieldPath="lc_lg";
            data.sId=sz_id;
            data.filename2="殡仪馆系统/骨灰处理/寄存登记";
            data.appid="business";
            this.$emit("openWin",JSON.stringify(data))
        },
        openLc2(item){
            let loc_ex1=item.loc_ex1;
            let loc_ex2=item.loc_id;
            let location=loc_ex1+","+loc_ex2
            let data={};
            data.buttonName="寄存登记"

            data.url="/commonEdit?fieldPath=sz%255Finfo&filename2="+escape(escape("骨灰处理/寄存登记2"))+"&sKey=740&appid=business&company=&sId=&location="+location+"&loc_id="+loc_ex2+"&paramKey=location,loc_id&modelId=3&title=业务管理&oldId=1&oldtitle=殡仪馆业务信息管理系统";
            this.$emit("openWin",JSON.stringify(data))



        },
        openCg(item){
           
            let sz_id=item.sz_id;
           /* let data={};
            data.buttonName="取走登记"

            data.url="/commonEdit?fieldPath=sz%255Finfo&filename2="+escape(escape("骨灰处理/取走登记"))+"&sKey=571&appid=business&company=&sId="+sz_id+"&modelId=3&title=业务管理&oldId=1&oldtitle=殡仪馆业务信息管理系统";
            this.$emit("openWin",JSON.stringify(data))*/

             let data={};
            data.buttonName="取走登记"
            data.url="/commonEdit";
            data.fieldPath="lc_lg";
            data.sId=sz_id;
            data.filename2="殡仪馆系统/骨灰处理/取走登记";
            data.appid="business";
            this.$emit("openWin",JSON.stringify(data))
        },

        cancelRg(item){
            let sz_id=item.sz_id;
            this.$confirm('确定取消寄存?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                   
                    this.$post("business","/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/取消寄存&isSend=Y",{"ids":sz_id}).then(data=>{
                         if(data[0].status=="+OK"){
                            this.$message({
                                message: unescape(data[0].msg),
                                    type: 'success'
                                });
                            this.goSearch()
                        }else{
                            this.$alert(unescape(data[0].msg), '错误提示', {
                                confirmButtonText: '确定',
                                callback: action => {}
                            });
                        }
                    })
                }).catch(() => {
                         
            });
        },
         handleNodeClick(data, checked, node) {
            if(checked === true) {
                this.areaId=data.id;
                //this.gm_id=data.pId;
                this.checkedId = data.id;
                this.$refs.elMenu.setCheckedKeys([data.id]);
                this.loadRight(data.id)
            } else {
                if (this.checkedId == data.id) {
                    this.$refs.elMenu.setCheckedKeys([data.id]);
                }
            }
        },
        handleClick(data,index){
            this.areaId=data.id;
         
            this.checkedId = data.id;
            this.active=this.areaId;
            this.roomActive=index;
            this.loadRight(data.id)
        },
        handleNodeClick2(data) {
            this.areaId=data.id;
           // this.gm_id=data.pId;
            this.checkedId = data.id;
            this.active=this.areaId;
            this.$refs.elMenu.setCheckedKeys([data.id]);
            this.loadRight(data.id)
        },
        delItem(item){
            let loc_id=item.loc_id;
            this.$confirm('确定删除该寄存位?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                   
                    this.$post("business","/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/寄存位删除&isSend=Y",{"ids":loc_id}).then(data=>{
                         if(data[0].status=="+OK"){
                            this.$message({
                                message: unescape(data[0].msg),
                                    type: 'success'
                                });
                            this.goSearch()
                        }else{
                            this.$alert(unescape(data[0].msg), '错误提示', {
                                confirmButtonText: '确定',
                                callback: action => {}
                            });
                        }
                    })
                }).catch(() => {
                         
            });
        },
        setItem(item){
            let loc_id=item.loc_id;
            let lg_status=item.loc_ex4;
            let msg="";
            let url="";
            if(lg_status=="Y"){
                msg="确定要停用该寄存位?";
                url="/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/寄存设置/停用&isSend=Y"
            }else{
                msg="确定要启用该寄存位?";
                url="/api/view/delCommonEdit?filename=殡仪馆系统/骨灰处理/寄存设置/启用&isSend=Y"
            }
            this.$confirm(msg, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                   
                    this.$post("business",url,{"ids":loc_id}).then(data=>{
                         if(data[0].status=="+OK"){
                            this.$message({
                                message: unescape(data[0].msg),
                                    type: 'success'
                                });
                            this.goSearch()
                        }else{
                            this.$alert(unescape(data[0].msg), '错误提示', {
                                confirmButtonText: '确定',
                                callback: action => {}
                            });
                        }
                    })
                }).catch(() => {
                         
            });
        },
         sysHandleScroll() {
            this.$refs.contents_left.scrollTop = this.$refs.contents.scrollTop
            this.$refs.contents_head_item.scrollLeft=this.$refs.contents.scrollLeft
            
        },
        checkedOne (fruitId) {
           console.log("1111111111111111111")
            let idIndex = this.fruitIds.indexOf(fruitId)
            if (idIndex >= 0) {
                // 如果已经包含了该id, 则去除(单选按钮由选中变为非选中状态)
                this.fruitIds.splice(idIndex, 1);
                let index=-1;
                for(let i=0;i<this.clickItems.length;i++){
                    let loc_id=this.clickItems[i].loc_id;
                    if(loc_id==fruitId){
                        index=i;
                    }
                }
                if(index>=0)
                    this.clickItems.splice(index, 1);
            } else {
                // 选中该checkbox
                this.fruitIds.push(fruitId)
                let item=null;
                console.log("fruitId======="+fruitId);
                for(let i=0;i<this.locItems.length;i++){
                    let child=this.locItems[i].child;
                    for(let j=0;j<child.length;j++){
                        let loc_id=child[j].loc_id;
                        if(loc_id==fruitId){
                            item=child[j];
                        }
                    }
                }
                if(item){
                    this.clickItems.push(item);
                }
                /*if(this.fruitIds.length == this.fruits.length){ 
                    this.isCheckedAll=true; 
                } else {
                    this.isCheckedAll=false; 
                }*/
            }
        },
        checkedMore(item){
            for(let i=0;i<item.length;i++){
                this.checkedOne(item[i].loc_id);
            }
        },
        checkedAll(item){
            console.log(item)
            for(let i=0;i<item.length;i++){
                this.checkedMore(item[i].child);
            }
        },
        itemClick(item,index,index2){
           
            
             if(this.isSelect=="Y"){
               // this.selectIndex=index+"-"+index2;
                this.clickItem=item.child[index2];
                
                this.fruitIds=[];
                this.checkedOne(item.child[index2].loc_id);
                console.log("fruitIds===================");
                console.log(this.fruitIds)
            }
        },
        openItem(item,index,index2){
            
            if(this.isSelect!="Y"){
                let loc_id=item.child[index2].jc_mainid;
                if(loc_id){
                    let datas={};
                    datas.buttonName="寄存位编辑";
                    datas.url="/commonEdit";
                    datas.sId=loc_id;
                    datas.width="80%";
                    datas.height="750px";
                    datas.filename2="殡仪馆系统/骨灰处理/寄存登记"
                    datas.appid="business";
                    this.$emit("openWin",JSON.stringify(datas))
                }
                
            }
        }
    }
}
</script>
<style scoped>
   
   .roomBtn{
    padding:10px;
   }
   .ginput{
    margin-left:5px;
    margin-right:5px;
    margin-top:5px;
   }
    .cold{

        height:100%;
        display:flex;
        flex-direction: column;
    }
    .tac{
        flex:1;
        width:100%;
        overflow: hidden;
    }
    .cols{
        height:100%;
        display:flex;
        flex-direction: column;
        padding:10px;
        padding-right:0;
        box-sizing: border-box;
    }
    .cols2{
        height:100%;
        display: flex;
        flex-direction: column;
        padding:10px;
        box-sizing: border-box;
        padding-right:2px;
    }
    .menu{
        flex:1;
        border:1px solid #ddd;
        background:#fff;
        border-radius: 5px;
        display:flex;
        flex-direction: column;
    }
    .mytree2{
        flex:1;
    }
    .tree_bottom{
        height:80px;
        padding:10px;
        box-sizing: border-box;
        border-top: 1px solid #ddd;
        background:#efefef;
    }
    .buttons{
        padding-bottom:10px;
    }
    .content{
         border:1px solid #ddd;
        flex:1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border-radius: 5px;
        background-color: #fff;
    }
    .title{
        height:30px;
        border:1px solid #ddd;
        line-height:30px;
        margin-bottom:5px;
        padding:5px;
        border-radius:5px;
       
        
        padding-left:10px;
    }
    .tab{
         background-color:cornflowerblue;
         color:#fff;
         width:60px;
         border-radius: 5px;
         text-align:center;
         cursor:pointer;
         display:inline-block;
         margin-right:5px;
    }
    .active{
        background:green;
    }
    .box-card{
        width:180px;
        height:200px;
        display: flex;
        flex-direction: column;
        box-shadow:0 2px 12px 0 rgba(0,0,0,.1);
        border-radius: 5px;
        float:left;
        margin-right:10px;
    }
    .bg1{
        background:rgb(200, 215, 243);
    }
    .bg2{
        background:rgb(4, 111, 193);
    }
    .bg3{
        background:rgb(241, 112, 161);
    }
    .bg5{
        background:#67C23A;
    }
    .bg6{
        background:red;
    }
    .bg7{
        background:yellow;
    }
    .bg8{
        background:green;
    }
    .bg9{
        background:blue;
    }
    .box-title{
        border-bottom:1px dashed cornflowerblue;
        height:50px;
        box-sizing: border-box;
        padding:10px;
    }
    .box-no{
        font-size:20px;
        color:cornflowerblue;
        font-weight: bold;
        float:left;
    }
    .box-name{
        float:right;
        font-size:13px;
    }
    
    .el-card__body{
        padding:0 !important;
        height:200px;
    }
    .box-content{
        padding:10px;
        font-size:14px;
        flex:1;
    }
    .box-footer{
        height:30px;
        border-top:1px dashed cornflowerblue;
        display:flex;
        flex-direction: row;
    }
    .box-footer i{
        color:cornflowerblue;
        margin-left:10px;
        cursor: pointer;
        line-height:30px
    }
    .isEdit i{
        color:rgb(34, 153, 34);
        margin-left:10px;
        cursor: pointer;
        line-height:30px
    }
    .contents_head{
        padding-left:20px;
        height:30px;
        border-bottom:1px solid #ddd;
        background-color: #f9fbff;
        line-height: 30px;
        overflow: auto;
        scrollbar-width: none; /* firefox */
        -ms-overflow-style: none; /* IE 10+ */
    }
    .contents_head::-webkit-scrollbar {
        display: none; /* Chrome Safari */
    }
    .contents_head_item{
        display:inline-block;
        width:130px;
        text-align: center;
        color:#475d81;
        font-weight: bold;
    }
    .contents_right{

        overflow:hidden;
        flex: 1;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        display:flex;
        flex-direction: column;
    }
    .content_main{

        border:1px solid #ddd;
        flex:1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border-radius: 5px;
        background-color: #fff;
    }
    .contents{
        flex: 1;
        overflow:hidden;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        display:flex;
        flex-direction: row;
        /*padding:10px;*/
        padding-left:0;
    }
    .contents_left{
        background-color: #f9fbff;
        border-right:1px solid #ddd;
        padding-top:20px;
        width:30px;
        display:flex;
        flex-direction: column;
        overflow: auto;
        scrollbar-width: none; /* firefox */
        -ms-overflow-style: none; /* IE 10+ */
    }
    .contents_left::-webkit-scrollbar {
        display: none; /* Chrome Safari */
    }
    .contents_left_head{
        height:50px;
    }
    .contents_left_content{
        flex:1;
    }
    .contents_left_content_item{
        
        /*border-bottom:1px solid #ddd;*/
        text-align:center;
        /*background:cornflowerblue;*/
        color:#475d81;
        font-weight: bold;
    }
        
    .gm{
        height:110px;
        width:100%;
        float:left;
    /* background-repeat: no-repeat;
        background-size:  100% 100%;
        background-image:url('../../img/gm/gm.png');*/
        
    }
    .gm_child{
        background:rgb(255,255,255,0.8);
        height:100%;
        display: flex;
        flex-direction: column;
    }
    .gm_content{
        flex:1;
        vertical-align: middle;
        text-align: center;

        display: flex;
        flex-direction: column;
        padding-top:10px;


    }
    .gm_content div{
        text-align: left;
        padding-left:5px;
    }
    .card_item{
        width:110px;
        display: inline-block;
        /*margin-left:10px;
        margin-top:10px;*/
        cursor: pointer;
        
    }
    .contents_gm{

        overflow:auto;
        flex: 1;
        padding:10px;
        text-align: left;
    
    }
    .car_row{
        white-spacing:nowrap;
    }
</style>
